package net.huashitong.supervision.task.dao;

import com.sirdc.modules.core.dao.GenericQuery;
import com.sirdc.modules.core.dao.StringDao;
import com.sirdc.modules.sys.filter.RoomUserFilter;
import com.sirdc.modules.utils.StringUtils;
import net.huashitong.supervision.task.entity.RoomUserEntity;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class RoomUserDao extends StringDao<RoomUserEntity> {


    public List<RoomUserEntity> queryFilter(RoomUserFilter filter) {
        GenericQuery query = createQuery("obj");
        if(StringUtils.isNotBlank(filter.getUserId())){

            query.append(" and obj.userId=:userId").setParam("userId",filter.getUserId());
        }
        if(StringUtils.isNotBlank(filter.getRoomId()))
        {

            query.append(" and obj.roomId=:roomId").setParam("roomId",filter.getRoomId());
        }
        query.append(" and obj.valid =:valid ").setParam("valid", filter.getValid() );

        return  query.listResult();

    }
}
